//
//  KRSearchNoDataCell.m
//  cookBook
//
//  Created by kuroken on 16/1/28.
//  Copyright © 2016年 kuroken. All rights reserved.
//

#import "KRSearchNoDataCell.h"
#import <PureLayout.h>

// cell重用标识
static NSString * const KRSearchNoData = @"searchNoData";

@interface KRSearchNoDataCell ()

@property (nonatomic, weak) UIImageView *noDataImageView;

@end

@implementation KRSearchNoDataCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    KRSearchNoDataCell *cell = [tableView dequeueReusableCellWithIdentifier:KRSearchNoData];
    if (!cell) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:KRSearchNoData];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsMake(0, 0, 0, MAXFLOAT);
        
        [self setupSubview];
        [self addConstraint];
    }
    return self;
}

/**
 *  初始化子控件
 */
- (void)setupSubview
{
    UIImageView *noDataImageView = [[UIImageView alloc] init];
    [noDataImageView setImage:[UIImage imageNamed:@"nodata_other_search"]];
    [self.contentView addSubview:noDataImageView];
    self.noDataImageView = noDataImageView;

}

/**
 *  添加约束
 */
- (void)addConstraint
{
    [self.noDataImageView autoCenterInSuperview];
    [self.noDataImageView autoSetDimensionsToSize:self.noDataImageView.image.size];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
